package org.yoki.edu.portal.web.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by kissy on 2017/3/2.
 */
@Component
public class SmsHttp {

    public static final String BASE_URL = "http://101.201.140.197:8080/sms.aspx?action={action}&userid={userid}&account={account}&password={password}&mobile={mobile}&content={content}&sendTime={sendTime}&extno={extno}";

    @Autowired
    private RestTemplate restTemplate;

    public void sendMsg(String cellphone, String code) {
        Map<String, Object> params = new HashMap();
        params.put("action", "send");
        params.put("userid", "98"); // 17
        params.put("account", "portal");
        params.put("password", "yzworld_portal"); // 1qaz2wsx
        params.put("mobile", cellphone);
        params.put("sendTime", "");
        params.put("extno", "");
        params.put("content", "【****】尊敬的用户，您的华发商都官方wifi验证码是:" + code + "，敬请使用。");
        //params.put("content","【云智天下】尊敬的用户您好，您的订单:"+code+"，订单号:2已开始处理，预计48小时完成配货上门安装。请保持家中有人，手机畅通。");

        String res = restTemplate.getForObject(BASE_URL, String.class, params); //.getForEntity(BASE_URL, String.class,params);
        System.out.println(res);
    }

    public static void main(String[] args) {

    }
}
